﻿/*
* ==============================================================================
*
* Filename: call_user_param_util
* Description: call_user_param_util
*
* Version: 1.0
* Created: 2020/9/2 17:49:04
* Compiler: Visual Studio 2019
*
* Author: Administrator
* Company: freelancer
*
* ==============================================================================
*/

namespace db_util {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.Threading.Tasks;
	using db_model;
	using MySql.Data.MySqlClient;

	public class call_user_param_util {
		public static call_user_param_model GetModel(string uuid) {
			var model = new call_user_param_model();
			string sql = "select id,unique_id,uuid,auto_open_page,home_url,extend_url,save_rec_path,auto_add_num_remote,auto_add_num_remote_flag,auto_add_num_local,auto_add_num_local_flag,local_city,local_city_code,conn_svr_ip,conn_svr_port,conn_local_ip,conn_local_port from call_user_param where uuid=?uuid limit 1";
			MySqlParameter[] parameters = {
	 new MySqlParameter("?uuid", MySqlDbType.VarChar,36)
				};
			parameters[0].Value = uuid;
			using (var dr = mysql_helper.GetDataReader(sql, parameters)) {
				if (dr.Read()) {
					model.id = int.Parse(dr["id"].ToString() == "" ? "-1" : dr["id"].ToString());
					model.unique_id = dr["unique_id"].ToString();
					model.uuid = dr["uuid"].ToString();
					model.auto_open_page = int.Parse(dr["auto_open_page"].ToString() == "" ? "-1" : dr["auto_open_page"].ToString());
					model.home_url = dr["home_url"].ToString();
					model.extend_url = dr["extend_url"].ToString();
					model.save_rec_path = dr["save_rec_path"].ToString();
					model.auto_add_num_remote = dr["auto_add_num_remote"].ToString();
					model.auto_add_num_remote_flag = int.Parse(dr["auto_add_num_remote_flag"].ToString() == "" ? "-1" : dr["auto_add_num_remote_flag"].ToString());
					model.auto_add_num_local = dr["auto_add_num_local"].ToString();
					model.auto_add_num_local_flag = int.Parse(dr["auto_add_num_local_flag"].ToString() == "" ? "-1" : dr["auto_add_num_local_flag"].ToString());
					model.local_city = dr["local_city"].ToString();
					model.local_city_code = dr["local_city_code"].ToString();
					model.conn_svr_ip = dr["conn_svr_ip"].ToString();
					model.conn_svr_port = int.Parse(dr["conn_svr_port"].ToString() == "" ? "-1" : dr["conn_svr_port"].ToString());
					model.conn_local_ip = dr["conn_local_ip"].ToString();
					model.conn_local_port = int.Parse(dr["conn_local_port"].ToString() == "" ? "-1" : dr["conn_local_port"].ToString());
				}
			}
			return model;
		}

	}
}